package com.neusoft.elmboot.controller;

import java.util.List;

import com.neusoft.elmboot.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.neusoft.elmboot.po.Cart;
import com.neusoft.elmboot.service.CartService;

/**
 * 购物车
 * Controller
 */
@Slf4j
@RestController
@RequestMapping(value = "/CartController")
public class CartController {
    @Autowired
    private CartService cartService;

    @RequestMapping(value = "/listCart")
    public Result<List<Cart>> listCart(Cart cart) throws Exception{
        List<Cart> list =  cartService.listCart(cart);
        log.info("调用接口：查询购物车信息");
        return Result.success(list);
    }

    @RequestMapping(value = "/saveCart")
    public Result<Integer> saveCart(Cart cart) throws Exception{
        log.info("调用接口：新增购物车");
        return Result.success(cartService.saveCart(cart));
    }

    @RequestMapping(value = "/updateCart")
    public Result<Integer> updateCart(Cart cart) throws Exception{
        log.info("调用接口：更新购物车信息");
        return Result.success(cartService.updateCart(cart));
    }

    @RequestMapping(value = "/removeCart")
    public Result<Integer> removeCart(Cart cart) throws Exception{
        log.info("调用接口：删除购物车信息");
        return Result.success(cartService.removeCart(cart));
    }
}
